Polymer({
    //定义卡片id，该id在card.html的<dom-module>标签中被引用。
    is: "PC-CARD-HTML-4804236383747498-01",
    properties: {
        card_title: {
            type: String,
            export: true,
            default: "通知公告"
        },
        query_type: {
            type: String,
            export: true
        },
        type_value: {
            type: String,
            export: true
        },
        page_size: {
            type: String,
            export: true
        },
        thumbnail: {
            type: String,
            export: true,
            default: "thumbnail.png"
        },
        target_platform: {
            type: String,
            export: true,
            default: "WEB"
        },
        first_title: {
            type: String
        },
        first_department: {
            type: String
        },
        first_time: {
            type: String
        },
        news: {
            type: Array
        }
    },
    ajaxRoot: location.origin,
    // ajaxRoot: "http://localhost:8080",
    ready: function() {
        var widget = this;
        $.get(widget.ajaxRoot + '/publicapp/sys/tzggxt/api/queryCardNotices.do', {
            key: widget.query_type,
            value: widget.type_value,
            pageSize: widget.page_size
        }).done(function(resp){
            var newsArr = [];
            // 左侧数据的展示
            if(resp.code === 200 && resp.notices) {
                $.each(resp.notices, function(idx, notice){
                    var time = notice.SEND_TIME ? notice.SEND_TIME.split(" ")[0] : "";
                    newsArr.push({
                        noticeTitle: notice.NOTICE_TITLE,
                        sendTime: time,
                        hasAttach: notice.TOKEN,
                        detailUrl: widget.ajaxRoot + '/publicapp/sys/tzggxt/noticeDetail.do?noticeId=' + notice.WID
                    });
                });
            }
            widget.news = newsArr;
            setTimeout(function(){
                window.parent.AmpUtils.niceScrollInit($("." + widget.is + " .amp-wf-body"));
            }, 750)
            widget.fire("widgetComplete");
        });
    }
});
